﻿using System.Collections;
using HardMock;
using HardMock.Domain;
using Rhino.Mocks;
using Xunit;

namespace Tests
{
    extern alias castlecore;

    public class HardMockFacadeTest
    {
        private static readonly castlecore::Castle.DynamicProxy.ProxyGenerator ProxyGenerator =
            new castlecore::Castle.DynamicProxy.ProxyGenerator();

        private readonly castlecore::Castle.DynamicProxy.IInterceptor interceptorMock;

        public HardMockFacadeTest()
        {
            var mockRepository = new MockRepository();
            interceptorMock = mockRepository.StrictMock<castlecore::Castle.DynamicProxy.IInterceptor>();
        }

        [Fact]
        public void Should_throw_exception_when_proxy_is_not_dependency_recorder()
        {
            Assert.Throws<HardMockException>(() => new object().Snapshot(null));
            Assert.Throws<HardMockException>(
                () => ProxyGenerator.CreateInterfaceProxyWithoutTarget<IEnumerable>(interceptorMock).Snapshot(null));
        }
    }
}